<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>历史记录 - 智能教育系统</title>
    <link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">
    <style>
        body {
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
            margin: 0;
            padding-top: 80px;
        }

        .history-container {
            max-width: 1200px;
            margin: 2rem auto;
            padding: 2rem;
            animation: fadeIn 0.5s ease;
        }

        @keyframes fadeIn {
            from {
                opacity: 0;
                transform: translateY(20px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        .history-card {
            background: white;
            border-radius: 15px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
            transition: all 0.3s ease;
            position: relative;
            overflow: hidden;
            margin-bottom: 1.5rem;
        }

        .history-card::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: linear-gradient(45deg, transparent, rgba(110, 142, 251, 0.1), transparent);
            transform: translateX(-100%);
            transition: transform 0.5s ease;
        }

        .history-card:hover::before {
            transform: translateX(100%);
        }

        .history-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 8px 15px rgba(0, 0, 0, 0.1);
        }

        .alert {
            padding: 1rem;
            border-radius: 8px;
            margin-bottom: 1rem;
            animation: slideIn 0.3s ease;
            position: relative;
            overflow: hidden;
        }

        .alert::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: linear-gradient(45deg, transparent, rgba(255,255,255,0.2), transparent);
            transform: translateX(-100%);
            transition: transform 0.5s ease;
        }

        .alert:hover::before {
            transform: translateX(100%);
        }

        @keyframes slideIn {
            from {
                transform: translateY(-10px);
                opacity: 0;
            }
            to {
                transform: translateY(0);
                opacity: 1;
            }
        }

        .history-header {
            padding: 1.5rem;
            border-bottom: 1px solid #e2e8f0;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .history-title {
            font-size: 1.25rem;
            font-weight: 600;
            color: #2d3748;
            margin: 0;
            transition: color 0.3s ease;
        }

        .history-card:hover .history-title {
            color: #6e8efb;
        }

        .history-meta {
            color: #718096;
            font-size: 0.875rem;
            margin-top: 0.5rem;
        }

        .history-content {
            padding: 1.5rem;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .history-info {
            flex: 1;
        }

        .info-item {
            margin-bottom: 0.5rem;
            display: flex;
            align-items: center;
            color: #4a5568;
        }

        .info-label {
            font-weight: 500;
            margin-right: 0.5rem;
            color: #718096;
        }

        .score-badge {
            background: linear-gradient(135deg, #6e8efb, #a777e3);
            color: white;
            padding: 0.5rem 1rem;
            border-radius: 20px;
            font-weight: 600;
            font-size: 1.25rem;
            box-shadow: 0 2px 4px rgba(110, 142, 251, 0.2);
            transition: all 0.3s ease;
        }

        .score-badge:hover {
            transform: scale(1.05);
            box-shadow: 0 4px 8px rgba(110, 142, 251, 0.3);
        }

        .empty-state {
            text-align: center;
            padding: 3rem;
            background: white;
            border-radius: 15px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
            animation: fadeIn 0.5s ease;
        }

        .empty-state-icon {
            font-size: 3rem;
            color: #cbd5e0;
            margin-bottom: 1rem;
        }

        .empty-state-text {
            color: #718096;
            font-size: 1.1rem;
        }

        .filter-section {
            margin-bottom: 2rem;
            display: flex;
            gap: 1rem;
            flex-wrap: wrap;
        }

        .filter-input {
            flex: 1;
            min-width: 200px;
            padding: 0.75rem 1rem;
            border: 2px solid #e2e8f0;
            border-radius: 8px;
            transition: all 0.3s ease;
            background: #f8fafc;
        }

        .filter-input:focus {
            outline: none;
            border-color: #6e8efb;
            box-shadow: 0 0 0 3px rgba(110, 142, 251, 0.1);
            background: white;
        }

        .filter-input:hover {
            border-color: #cbd5e0;
        }

        .date-badge {
            background: #edf2f7;
            color: #4a5568;
            padding: 0.25rem 0.75rem;
            border-radius: 15px;
            font-size: 0.875rem;
            transition: all 0.3s ease;
        }

        .history-card:hover .date-badge {
            background: #e2e8f0;
            color: #2d3748;
        }
    </style>
</head>
<body>
    <!-- 引入导航栏 -->
    <div th:replace="fragments/navbar :: navbar"></div>

    <div class="history-container">
        <div class="flex justify-between items-center mb-6">
            <h1 class="text-3xl font-bold text-gray-800">历史记录</h1>
        </div>

        <!-- 提示消息 -->
        <div th:if="${success}" class="alert bg-green-100 text-green-700" th:text="${success}"></div>
        <div th:if="${error}" class="alert bg-red-100 text-red-700" th:text="${error}"></div>

        <!-- 筛选区域 -->
        <div class="filter-section">
            <input type="text" id="searchInput" class="filter-input" placeholder="搜索考试名称或学生姓名...">
            <input type="date" id="dateFilter" class="filter-input">
        </div>

        <!-- 历史记录列表 -->
        <div id="historyList">
            <div th:each="record : ${records}" class="history-card">
                <div class="history-header">
                    <div>
                        <h3 class="history-title" th:text="${record.exam != null ? record.exam.examName : '未关联考试'}">考试名称</h3>
                        <div class="history-meta">
                            <span class="date-badge" th:text="${#temporals.format(record.createdAt, 'yyyy-MM-dd HH:mm')}">提交时间</span>
                        </div>
                    </div>
                    <div class="score-badge" th:text="${record.score != null ? record.score + '分' : '未评分'}">分数</div>
                </div>
                <div class="history-content">
                    <div class="history-info">
                        <div class="info-item">
                            <span class="info-label">学生：</span>
                            <span th:text="${record.studentName}">学生姓名</span>
                        </div>
                        <div class="info-item">
                            <span class="info-label">科目：</span>
                            <span th:text="${record.exam != null ? record.exam.subject : '未知科目'}">科目</span>
                        </div>
                        <div class="info-item">
                            <span class="info-label">班级：</span>
                            <span th:text="${record.exam != null ? record.exam.classEntity.className + ' (' + record.exam.classEntity.grade + ')' : '未知班级'}">班级</span>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- 空状态 -->
        <div th:if="${#lists.isEmpty(records)}" class="empty-state">
            <div class="empty-state-icon">📝</div>
            <p class="empty-state-text">暂无历史记录</p>
        </div>
    </div>

    <script>
        // 添加页面滚动效果
        window.addEventListener('scroll', function() {
            const historyCards = document.querySelectorAll('.history-card');
            const scrollPosition = window.scrollY;
            
            historyCards.forEach((card, index) => {
                if (scrollPosition > 100) {
                    card.style.transform = `translateY(-${Math.min(5, index * 0.5)}px)`;
                } else {
                    card.style.transform = 'translateY(0)';
                }
            });
        });

        // 搜索和筛选功能
        const searchInput = document.getElementById('searchInput');
        const dateFilter = document.getElementById('dateFilter');
        const historyCards = document.querySelectorAll('.history-card');

        function filterRecords() {
            const searchTerm = searchInput.value.toLowerCase();
            const selectedDate = dateFilter.value;

            historyCards.forEach(card => {
                const title = card.querySelector('.history-title').textContent.toLowerCase();
                const student = card.querySelector('.info-item:first-child span:last-child').textContent.toLowerCase();
                const date = card.querySelector('.date-badge').textContent;

                const matchesSearch = title.includes(searchTerm) || student.includes(searchTerm);
                const matchesDate = !selectedDate || date.includes(selectedDate);

                if (matchesSearch && matchesDate) {
                    card.style.display = 'block';
                    setTimeout(() => {
                        card.style.opacity = '1';
                        card.style.transform = 'translateY(0)';
                    }, 10);
                } else {
                    card.style.opacity = '0';
                    card.style.transform = 'translateY(20px)';
                    setTimeout(() => {
                        card.style.display = 'none';
                    }, 300);
                }
            });
        }

        searchInput.addEventListener('input', filterRecords);
        dateFilter.addEventListener('change', filterRecords);

        // 添加卡片点击效果
        document.querySelectorAll('.history-card').forEach(card => {
            card.addEventListener('click', function() {
                this.style.transform = 'scale(0.98)';
                setTimeout(() => {
                    this.style.transform = 'translateY(-5px)';
                }, 100);
            });
        });
    </script>
</body>
</html> 